/**
 * Copyright (c) 2011 Tomi Paananen.
 *
 * Part of Quick Gestures engine library.
 */

#ifndef XMLPARSER_H
#define XMLPARSER_H

// Qt includes
#include <QObject>
#include <QVector>
#include <QXmlStreamAttributes>

// Forward declarations
class Gesture;
class QIODevice;
class QXmlStreamReader;
class QXmlStreamWriter;


class XmlParser : public QObject
{
    Q_OBJECT

public:
    explicit XmlParser(QObject *parent = 0);
    virtual ~XmlParser();

public:
    int writeGestures(QIODevice *target, QList<Gesture*> &gestures);
    int readGestures(QIODevice *source, QList<Gesture*> &gestures);

private:
    int writeGesture(Gesture *gesture);
    void parseGesturePoints(Gesture *gesture, QString pointsString) const;
    void parseGestureAttributes(Gesture *gesture,
                                QXmlStreamAttributes attributes) const;
    int tokenCount(QIODevice *source);

signals:
    void progress(int percentsComplete);
    void gestureParsed(Gesture *gesture);

private: // Data
    QXmlStreamReader *mReader;
    QXmlStreamWriter *mWriter;
};


#endif // XMLPARSER_H

// End of file.
